package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Member;
import com.sk.bilibili.dto.MemberInfo;
import com.sk.bilibili.dto.QrCode;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.MemberService;
import com.sk.bilibili.service.QrCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
* @author 邵康
* @date 2021/11/22 23:08
*/
@CrossOrigin
@RestController
@RequestMapping("/qrCode")
@Api(tags = "二维码")
public class QrCodeController {

    @Autowired
    private QrCodeService qrCodeService;

    @ApiOperation("扫码登录 唯一标识必须有  登录当前手机用户")
    @GetMapping("/scan")
    public R<Void> scan(String code){
        return qrCodeService.scan(code);
    }

    @ApiOperation("获取登录二维码")
    @GetMapping("/qrCode")
    public R<QrCode> qrCode(){
        return qrCodeService.qrCode();
    }

    @ApiOperation("检测二维码是否扫码")
    @GetMapping("/check")
    public R<Member> check(String code){
        return qrCodeService.check(code);
    }

    @ApiOperation("用于生成二维码")
    @GetMapping("/generate")
    public void generate(String info, HttpServletResponse response){
        qrCodeService.generate(info,response);
    }

}
